package com.SMSReader;

import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast; 

public class SMSSender extends Activity {

    private Button button1;
    private EditText txt_PhoneNumber;
    private EditText txt_Content;
    
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button1 = (Button)findViewById(R.id.btnSend);
        txt_PhoneNumber= (EditText)findViewById(R.id.edtPhoneNo);
        txt_Content= (EditText)findViewById(R.id.edtContent);
        
        button1.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View v) {
        		String phoneNo = txt_PhoneNumber.getText().toString();
        		String message = txt_Content.getText().toString();
        		if (phoneNo.length() > 0 && message.length() > 0){
        			//call sendSMS to send message to phoneNo
        			sendSMS(phoneNo, message);
        		}
        		else
        			Toast.makeText(getBaseContext(),
        				"Please enter both phone number and message.",
        				Toast.LENGTH_SHORT).show();
        	}
        });
    	txt_PhoneNumber.setText("");
    	txt_Content.setText("");
    	Toast toast=Toast.makeText(this, "Sending Complete",Toast.LENGTH_LONG);
    	toast.show();
    }
    private void sendSMS(String phoneNumber, String message) {
    	SmsManager.getDefault().sendTextMessage(phoneNumber, null, message, null, null);
    
    }
    
    
}